Skip to content

fix(tests): remove stale contract health import - #8974

Merged
huangruiteng merged 1 commit into
mainfrom
codex/contract-health-unused-import-20261118
Nov 18, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/contract-health-unused-import-20261118

Conversation

@huangruiteng

Copy link
Copy Markdown
Collaborator

kernel-static-checks currently fails on main because test_contract_health.py imports display_report_text without using it. Remove the stale import so the existing full Ruff gate can run cleanly; runtime behavior is unchanged.

Validation:

  • uvx ruff@0.15.22 check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentation
  • python -m pytest -q --no-cov tests/control_plane/test_contract_health.py (21 passed)
  • LoopX public-boundary scan clean for the changed file

Signed-off-by: huangruiteng <huangrt01@163.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

已针对 PR #8974 exact head 507bfb3698de0aad8320be1f0670686e1f7503bd 完成完整代码核对与本地验证(审查结论:APPROVE,无 P0/P1/P2 阻断问题)。

动机 / Motivation

受影响调用方与贡献者:所有运行仓库 Ruff 静态门禁(ruff check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentation)及 kernel-static-checks 的开发者与 PR 提交者(例如 PR #8975 也在该位置触发失败)。

修改前(main 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d):tests/control_plane/test_contract_health.py 第 10 行仍导入未使用的 display_report_text,导致全量声明范围的 Ruff 检查以 F401 退出码 1 失败。修改后(507bfb3698de0aad8320be1f0670686e1f7503bd):仅删除该行过时 import(-1 行),完整保留该测试文件的全部 21 项 contract-health 用例与身份/JSON 投影断言。

可观测结果:在 513b6f16 基线复现单条 F401 报错;在 exact head 507bfb3698 上完整 Ruff 范围返回 All checks passed!,mypy(17 个源文件)0 错误,pytest -q --no-cov tests/control_plane/test_contract_health.py 21 passed in 7.85s(0 skipped),loopx canary premerge --tier quick 与公共边界扫描(errors=0, warnings=0)全部通过。

非目标边界:本 PR 仅修复测试文件的过时导入 lint 缺陷,不修改生产代码 loopx/paths.py 或 loopx/contract.py 中的 display_report_text 实现,不处理其余分支上并存的同名重复 PR(如 #8969)关闭动作,也不授予合入权限。

改动思路 / Approach

只删除未使用的测试导入是最直接且可逆的单一边界修复,避免通过配置屏蔽 F401 规则或无故改写测试断言。全仓检索确认生产代码 loopx/contract.py 与 tests/canary/test_git_path_display.py 仍正常使用 loopx.paths.display_report_text,而 test_contract_health.py 已改用 report_json_text 与 display_report_value,因此删除该导入不削弱任何回归覆盖。

当前 PR 边界与结论依据:仅修改 tests/control_plane/test_contract_health.py 一处 import;未引入新测试脚手架、helper 或默认行为变化。

具体改动 / Changes

本 PR 为纯测试清理(1 file changed, 0 insertions(+), 1 deletion(-)),无生产代码、配置或 RFC 变更:

  1. tests/control_plane/test_contract_health.py(+0 / -1):删除第 10 行 from loopx.paths import display_report_text,保留 report_json_text、check_contract、display_report_value 及全部 21 项断言。

重复 PR 与价值评估

核对开放队列确认:PR #8969(d01c512ffc,作者 loopx-agent,基于更早 68440058)在 test_contract_health.py 上包含完全一致的 1 行删除,此外 #8958、#8956、#8953、#8950、#8949、#8948、#8946、#8941 等更大范围 PR 也顺带清理了该行。PR #8974 并非新增一次性 smoke 或刷量测试,而是真实修复 main@513b6f16 上复现的 F401 门禁阻断,并已通过 kernel-static-checks 与 Sign-off;就本 PR 自身改动而言质量合格,合并其中之一后应关闭重复的 #8969。

对主干的风险 / Risks

  • 回归与覆盖面风险:极低。仅删除静态未引用的导入符号;21 项 contract-health 测试在 507bfb3698 全数通过,且 loopx.paths.display_report_text 仍由 loopx/contract.py 与 tests/canary/test_git_path_display.py 独立守护。
  • 本地与 CI 验证明细(exact head 507bfb3698de0aad8320be1f0670686e1f7503bd):
    • PASS 基线对照 ruff check(513b6f16):精确复现 F401 loopx.paths.display_report_text imported but unused(L10:25)。
    • PASS uv run --extra test python -m ruff check tests loopx/canary loopx/control_plane loopx/domain_packs loopx/presentation:All checks passed!。
    • PASS uv run --extra test mypy:Success: no issues found in 17 source files。
    • PASS uv run --extra test python -m pytest -q --no-cov tests/control_plane/test_contract_health.py:21 passed in 7.85s。
    • PASS uv run --extra test loopx canary premerge --tier quick --from-git-diff --git-diff-base 513b6f168a405d5c071c79ae23fb18d2b4f5ae5d:ok=true, merge_gate_passed=true, failures=0。
    • PASS loopx check --scan-path tests/control_plane/test_contract_health.py:ok=True (errors=0, warnings=0)。
    • DIAGNOSTIC(非本 PR 回归):GitHub Actions 上 kernel-static-checks、Sign-off、inspect-pr-diff、dependency-review、kernel-contracts、typescript-core (1/3)-(3/3) 与 stage2c 均 SUCCESS;13 项浏览器/分片/覆盖率 job 为 CANCELLED(0 FAILURE),故 merge_state 仍为 BLOCKED(独立合入门禁)。

我的整体评价 / Verdict

  • Long-horizon 影响:preserved — 仅移除测试文件一条未使用的 import,恢复主干静态检查可用性,不改变控制面运行时行为与历史契约。
  • User-experience 影响:not_applicable — 纯测试 lint 修复,无前端、CLI 输出或打包表面改动,visual_review 为 not_applicable。

改动最小、证据完备、无阻断发现,予以 APPROVE;合入协调时建议同步关闭同质 PR #8969。

English verdict: APPROVE exact head 507bfb3; independently reproduced the F401 unused-import failure on main@513b6f16 and verified full Ruff scope, 17-file mypy, 21/21 contract-health pytest cases, quick premerge canary, and public boundary check pass (open PR #8969 carries the identical 1-line fix and can be closed upon merge).

@huangruiteng
huangruiteng merged commit d64b9c5 into main Nov 18, 2026
21 of 34 checks passed
@huangruiteng
huangruiteng deleted the codex/contract-health-unused-import-20261118 branch November 18, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants